@echo off
chcp 65001 >nul
echo ========================================
echo    ITS Development Mode Startup
echo ========================================
echo.
echo Starting development environment with hot reload...

cd /d "%~dp0"

echo [1/4] Stopping any existing containers...
docker-compose -f docker-compose.dev.yml down

echo [2/4] Starting database service...
docker-compose -f docker-compose.dev.yml up -d database

echo Waiting for database to start...
timeout /t 5 /nobreak >nul

echo [3/4] Starting backend service with hot reload...
docker-compose -f docker-compose.dev.yml up -d backend

echo Waiting for backend service to start...
timeout /t 10 /nobreak >nul

echo [4/4] Starting frontend service with hot reload...
docker-compose -f docker-compose.dev.yml up -d frontend

echo [5/4] Starting Nginx proxy...
docker-compose -f docker-compose.dev.yml up -d nginx

echo.
echo ========================================
echo    Development environment started!
echo ========================================
echo.
echo Features:
echo - Backend Hot Reload: Enabled
echo - Frontend Hot Reload: Enabled
echo - Database: PostgreSQL
echo.
echo Access URLs:
echo - Full System: http://localhost:8080
echo - API Docs: http://localhost:8001/docs
echo - Backend API: http://localhost:8001/api
echo.
echo Development commands:
echo - View logs: docker-compose -f docker-compose.dev.yml logs
echo - Stop services: docker-compose -f docker-compose.dev.yml down
echo - Restart service: docker-compose -f docker-compose.dev.yml restart [service]
echo.
echo Now you can edit code and see changes automatically!
echo.